package Other;

import java.util.Comparator;

public class Demo3 {
    public static void main(String[] args) {
        Comparator<Student> c1 = new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.age - o2.age;
            }
        };

        Comparator<Student> c2 = (Student o1, Student o2) -> {
            return o1.age - o2.age;
        };

        Comparator<Student> c3 = (Student o1, Student o2) -> o1.age - o2.age;

        Comparator<Student> c4 = (o1, o2) -> o1.age - o2.age;

        // 通过一个方法引用搞定
        Comparator<Student> c5 = Comparator.comparingInt(o -> o.age);
    }
}
